package com.xthink.common.utils;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class OrderNumberUtils {
    public static  String getTCNumber(){

        DateTime date = DateUtil.date();
        String dateString = DateUtil.format(date, "yyyyMMddHHmmss");

        Snowflake snowflake = IdUtil.getSnowflake(1, 1);
        long l = snowflake.nextId();
        String s = Long.toString(l);
        String substring = s.substring(s.length() - 8);

        log.info("OrderNumber:"+"TC"+dateString+substring);

        return  "TC" + dateString + substring;

    }

    public static  String getCTCNumber(){

        DateTime date = DateUtil.date();
        String dateString = DateUtil.format(date, "yyyyMMddHHmmss");

        Snowflake snowflake = IdUtil.getSnowflake(1, 1);
        long l = snowflake.nextId();
        String s = Long.toString(l);
        String substring = s.substring(s.length() - 8);

        log.info("OrderNumber:"+"CTC"+dateString+substring);

        return  "CTC" + dateString + substring;

    }
}
